import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { MessageService } from './../../core/service/message.service';

@Component({
    selector: 'app-breadcrumb',
    templateUrl: './breadcrumb.component.html',
    styleUrls: ['./breadcrumb.component.scss']
})
export class MyBreadcrumbComponent implements OnInit {

    private _rb: LayoutRouteStatus = {
        isHiddeBreadcrumb: false,
        breadcrumbs: [{ name: 'layout', url: '/member/center/account/setting' }]
    };
    isShowItem: Boolean = false;
    constructor(
        private _title: Title,
        private message: MessageService
    ) { }

    ngOnInit() {
        this.message.getBreadcrumb().subscribe((e: LayoutRouteStatus) => {
            this._rb = e;
            this.isShowItem = this._rb.breadcrumbs.length > 1 ? true : false;
            this._title.setTitle(e.breadcrumbs[e.breadcrumbs.length - 1].name);
        });
    }
    public change(e) {

    }
}
/**
 * @isHiddeBreadcrumb 是否隐藏面包屑 (可選) true:隐藏 | false && null: 展示
 * @breadcrumbs 路由節點集合
 */
export interface LayoutRouteStatus {
    isHiddeBreadcrumb?: boolean;
    breadcrumbs: Array<BreadcrumbData>;
}
/**
 * @name 当前路由展示名称（有值=需跳转：无值=不跳转）
 * @url 须有跳转的路由 (可選)
 */
export interface BreadcrumbData {
    name: string;
    url?: string;
}